import java.util.*;
import junit.framework.TestCase;
import org.junit.Test;
public class ArraysUnitTest extends TestCase {
    ArraysUnit x=new ArraysUnit();
    int a[] = {9,8,7,6,5,4,3,2,1} ;
    int b[]={6,5,4,3,2,1};

    @Test

    public void testNormalsort(){     //sort测试正常情况
        Arrays.sort(a);
        assertEquals("1 2 3 4 5 6 7 8 9",x.paixu());
    }

    @Test

    public void testBoundarysort(){     //sort测试边界情况
        Arrays.sort(b);
        //assertEquals("0",x.paixu());
    }

    @Test

    public void testExceptionsort(){    //sort测试异常情况
        Arrays.sort(b);
        //assertEquals("1 2 3 4 5 6 7 8 9",x.paixu());
    }

    @Test

    public void testNormalbinarySearch(){    //binarySearch测试正常情况
        Arrays.sort(a);
        int index1 = Arrays.binarySearch(a,4);
        int index2 = Arrays.binarySearch(a,5);
        assertEquals("3",index1+"");
        assertEquals("4",index2+"");
    }
    @Test
    public void testBoundarybinarySearch(){     //binarySearch测试边界情况
        Arrays.sort(a);
        int index1 = Arrays.binarySearch(a,1);
        int index2 = Arrays.binarySearch(a,9);
        assertEquals("0",index1+"");
        assertEquals("8",index2+"");
    }
    @Test
    public void testExceptionbinarySearch(){     //binarySearch测试异常情况
        Arrays.sort(a);
        int index1 = Arrays.binarySearch(a,0);
        //assertEquals("0",index1+"");
    }
}
